<form action="shop_pay.manage.php" id="form1" name="form1" method="post">
<input type="hidden" name="action" value="artificial_save" />
<table border="0" cellpadding="0" cellspacing="0" class="from_table">
	<tr>
		<th><tpl> $langSysShopPayMemberName </tpl>:</th>
	  <td width="480" class="td rowform"><input name="member_name" class="txtinput" type="text" id="member_name" maxlength="100" onkeydown="$('#tr_netx_step').css('display','');$('#tr_second').css('display','none');$('#tr_submit').css('display','none');" /></td>
		<td class="vtop tips2"><label style="display:none" for="member_name" class="wrong" metaDone="true" generated="true"></label></td>
	</tr>
	<tr id="tr_netx_step">
		<th></th>
		<td width="480" class="td rowform"><div style="float:left; padding-left:20px">
		<span class="btn_left"><input type="button" name="next_step" id="next_step" value="<tpl> $langSysShopPayNextStep </tpl>" class="btn_submit"/></span>
	  </div></td>
		<td class="vtop tips2"></td>
	</tr>
	<tr id="tr_second" style="display:none"></tr>
	<tr id="tr_submit" style="display:none">
		<th></th>
		<td width="480" class="td rowform">
		<div style="float:left; padding-left:20px">
			<span class="btn_left"><input type="submit" class="btn_submit" value="<tpl> $langSysShopPayModeSubmit </tpl>" /></span></div>
	  </td>
		<td class="vtop tips2"></td>
	</tr>
</table>
</form>

<script>
$(document).ready(function() {
	//下一步操作
	$('#next_step').click(function(){
		if($('#member_name').val() != ''){
			ajax_search_member();
		}else{
			alert('<tpl> $errSysShopPayMemberNameIsEmpty </tpl>');
		}
	});
	
	var options = {
		beforeSubmit:  function(){showLoading(showSaveText);},
		success:       function(msg){
							hideLoading();
							showMessage(msg.message,msg.type);
							if(msg.type == '1'){
								ST(0,0);
								ShowDiv = "result_content";
								getPageContent("shop_pay.manage.php?action=detail_list");
							}
						},
		type:      'post',
		dataType:  'json'
	};
	
	//对表单做的验证定义
	$("#form1").validate({
		errorClass: "wrong",
		rules: {
			member_name: {required:true},
			shop_time: {
				required:function(){
					if($('#sel_operate_0').attr('checked') == true){
						<tpl> if $shop_pay_mode eq '1' </tpl>
						true
						<tpl> else </tpl>
						false
						<tpl> /if </tpl>
					}else{
						return false;
					}
				},
				number:function(){
					if($('#sel_operate_0').attr('checked') == true){
						<tpl> if $shop_pay_mode eq '1' </tpl>
						true
						<tpl> else </tpl>
						false
						<tpl> /if </tpl>
					}else{
						return false;
					}
				}
			},
			product_number: {
				required:function(){
					if($('#sel_operate_0').attr('checked') == true){
						<tpl> if $shop_pay_mode eq '1' </tpl>
						true
						<tpl> else </tpl>
						false
						<tpl> /if </tpl>
					}else{
						return false;
					}
				},
				number:function(){
					if($('#sel_operate_0').attr('checked') == true){
						<tpl> if $shop_pay_mode eq '1' </tpl>
						true
						<tpl> else </tpl>
						false
						<tpl> /if </tpl>
					}else{
						return false;
					}
				}				
			},
			mode_id: {
				required:function(){
					if($('#sel_operate_1').attr('checked') == true){
						return true
					}else{
						return false;
					}
				}
			}
		},
		messages: {
			member_name: {required:"<tpl> $errSysShopPayMemberNameIsEmpty </tpl>"},
			shop_time: {required:"<tpl> $errSysShopPayModeShopTimeIsNotNumber </tpl>",number:"<tpl> $errSysShopPayModeShopTimeIsNotNumber </tpl>"},
			product_number: {required:"<tpl> $errSysShopPayModeProductNumberIsNotNumber </tpl>",number:"<tpl> $errSysShopPayModeProductNumberIsNotNumber </tpl>"},
			mode_id: {required:"<tpl> $errSysShopPayModeIsEmpty </tpl>"}
		},
		submitHandler: function() {
			$('#form1').ajaxSubmit(options);
		}
	});
});

//检查会员名是否存在
function ajax_search_member(){
	$.ajax({
		url: "shop_pay.manage.php",
		<tpl> if $NCharset eq 'UTF-8' </tpl>
		data: 'action=search_member&member_name='+$('#member_name').val(),
		<tpl> else </tpl>
		data: 'action=search_member&member_name='+escape($('#member_name').val()),
		<tpl> /if </tpl>
		type:'post',
		dataType:"html",
		beforeSubmit:  showLoading(showText),
		success: function(msg){
			hideLoading();
			if(msg == '0'){
				showMessage('<tpl> $errSysShopPayMemberIsNotHaving </tpl>',0);
				$('#tr_netx_step').css('display','');//显示第一步
				$('#tr_second').css('display','none');//隐藏第二步
				$('#tr_submit').css('display','none');//隐藏提交按钮
			}else{
				$('#tr_second').html(msg);
				$('#tr_netx_step').css('display','none');//隐藏第一步
				$('#tr_second').css('display','');//显示第二步
				$('#tr_submit').css('display','');//显示提交按钮
			}
		}
	});
	return false;
}
</script>